package org.yelongframework.excel.data.fill.sheet.mode.forcopy.down;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 简单实现
 * 
 * @since 1.0.0
 */
public class SimpleDownForCopySheetDataFillDataSupplier implements DownForCopySheetDataFillDataSupplier {

	/** 列数据供应商映射 */
	private final Map<Integer, DownForCopySheetDataFillDataSupplier> columnDataSupplierMap = new LinkedHashMap<>();

	// ==================================================列数据供应商映射==================================================

	/**
	 * 添加列数据供应商
	 * 
	 * @param column       列
	 * @param dataSupplier 数据供应商
	 * @return this
	 */
	public SimpleDownForCopySheetDataFillDataSupplier addColumnDataSupplier(int column,
			DownForCopySheetDataFillDataSupplier dataSupplier) {
		columnDataSupplierMap.put(column, dataSupplier);
		return this;
	}

	// ==================================================获取数据值==================================================

	@Override
	public Object get(int currentRowIndex, int currentColumnIndex, int currentCount) throws Exception {
		DownForCopySheetDataFillDataSupplier dataSupplier = columnDataSupplierMap.get(currentColumnIndex);
		return null == dataSupplier ? null : dataSupplier.get(currentRowIndex, currentColumnIndex, currentCount);
	}

}
